class Animals{   //将dog和cat共同定义为一个大类Animals;此方法就叫做继承
    String name;
    public int age;
    String color;
    public void eat(){
        System.out.println(this.name+"正在吃饭");
    }

    public Animals(String name, int age, String color) {  //初始化父亲成员时只有一种方法：调用构造方法
        this.name = name;
        this.age = age;
        this.color = color;
    }
}

class  Dog extends Animals{   //用extends函数共用类中的成员变量/字段
   public Dog(){
       super("小黑",2,"黑");//父类带有3个参数的构造方法
   }

    public void bark(){
        System.out.println(this.name+"正在汪汪汪！");}
}

class Cat extends Animals {
   public Cat(String name, int age, String color){
       super(name, age, color);
   }
    public void miaomiao(){
        System.out.println(this.name+"正在喵喵叫!");}
}

public class test {
    public static void main(String[] args) { //main中该怎么用怎么用
         Dog dog=new Dog();
         dog.bark();
         dog.eat();

        Cat cat=new Cat("小花",4,"花色");
        cat.eat();
        cat.miaomiao();
    }

}
